/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.kipme.connectors;

import java.net.MalformedURLException;
import java.net.URL;
import javax.xml.ws.BindingProvider;
import org.kipme.department.*;


/**
 *
 * @author Domyślny
 */
public class DepartmentWSConnector{
    
    private static int FocusedDepartmentId = 1;
    
    private static CentralService_Service service = new CentralService_Service();
    
    public static void SetNewWSDLLocation(String url) throws MalformedURLException, Exception{
        //((BindingProvider)service).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "url");
        //CentralService_Service.setWsdlLocation(new URL(url));
        try{
        service = new CentralService_Service(new URL(url));
        }
        catch(Exception ex){
            service = new CentralService_Service();
            throw new Exception("Zły url!");
        }
    }
    
    public static java.util.List<Category> getCategoryList() throws MalformedURLException {
        CentralService port = service.getCentralServiceImplPort();
        return port.getCategoryList();
    }
    
    public static java.util.List<org.kipme.department.Order> checkWaitingOrders() throws MalformedURLException {
        CentralService port = service.getCentralServiceImplPort();
        return port.checkWaitingOrders();
    }

    public static java.util.List<ProductInfo> getProductInfo() throws MalformedURLException {
        CentralService port = service.getCentralServiceImplPort();
        return port.getProductInfo();
    }

    public static java.util.List<Transaction> getTransactionSummary() throws MalformedURLException {
        CentralService port = service.getCentralServiceImplPort();
        return port.getTransactionSummary();
    }

    public static void updateOrderState(Order order) throws BusinessException_Exception, MalformedURLException {
        CentralService port = service.getCentralServiceImplPort();
        port.updateOrderState(order);
    }

    public static Product getProductByProductCode(java.lang.String productCode) throws MalformedURLException {
        CentralService port = service.getCentralServiceImplPort();
        return port.getProductByProductCode(productCode);
    }

    public static java.util.List<ProductType> getProductTypeList() throws MalformedURLException {
        CentralService port = service.getCentralServiceImplPort();
        return port.getProductTypeList();
    }

    public static java.util.List<Product> getProductsByCategory(java.lang.String categoryCode) throws MalformedURLException {
        CentralService port = service.getCentralServiceImplPort();
        return port.getProductsByCategory(categoryCode);
    }

    public static java.util.List<Product> getProductsByType(java.lang.String typeCode) throws MalformedURLException {
        CentralService port = service.getCentralServiceImplPort();
        return port.getProductsByType(typeCode);
    }

    public static java.util.List<Transaction> getTransactions(javax.xml.datatype.XMLGregorianCalendar startDate, javax.xml.datatype.XMLGregorianCalendar endDate) throws MalformedURLException {
        CentralService port = service.getCentralServiceImplPort();
        return port.getTransactions(startDate, endDate);
    }

    public static java.util.List<Transaction> getTransactionsByProductCode(java.lang.String productCode) throws MalformedURLException {
        CentralService port = service.getCentralServiceImplPort();
        return port.getTransactionsByProductCode(productCode);
    }

    /**
     * @return the FocusedDepartmentId
     */
    public static int getFocusedDepartmentId() {
        return FocusedDepartmentId;
    }

    /**
     * @param aFocusedDepartmentId the FocusedDepartmentId to set
     */
    public static void setFocusedDepartmentId(int aFocusedDepartmentId) {
        FocusedDepartmentId = aFocusedDepartmentId;
    }
}
